<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/snowzhao/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/snowzhao/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/snowzhao/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/snowzhao/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/snowzhao/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/snowzhao/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/snowzhao/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">










<meta name="description" content="创建一个类运行下，快速生成你需要的dimens文件中的数据，解放你每次需要每次添加一个。 第一步：创建一个类TestDimenTool(注意文件路径需要写对)，要编写sp、px单位的更改end字符串中的后缀；   12345678910111213141516171819202122232425262728293031323334353637383940public class TestDimen">
<meta property="og:type" content="article">
<meta property="og:title" content="studio 快速生成dimens文件">
<meta property="og:url" content="https://vincent_zyt.gitee.io/snowzhao/2019/08/07/studio-快速生成dimens文件/index.html">
<meta property="og:site_name" content="snowzhao博客">
<meta property="og:description" content="创建一个类运行下，快速生成你需要的dimens文件中的数据，解放你每次需要每次添加一个。 第一步：创建一个类TestDimenTool(注意文件路径需要写对)，要编写sp、px单位的更改end字符串中的后缀；   12345678910111213141516171819202122232425262728293031323334353637383940public class TestDimen">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2019-08-07T02:59:13.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="studio 快速生成dimens文件">
<meta name="twitter:description" content="创建一个类运行下，快速生成你需要的dimens文件中的数据，解放你每次需要每次添加一个。 第一步：创建一个类TestDimenTool(注意文件路径需要写对)，要编写sp、px单位的更改end字符串中的后缀；   12345678910111213141516171819202122232425262728293031323334353637383940public class TestDimen">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/snowzhao/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://vincent_zyt.gitee.io/snowzhao/2019/08/07/studio-快速生成dimens文件/">





  <title>studio 快速生成dimens文件 | snowzhao博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/snowzhao/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">snowzhao博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">蜕变</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-首页">
          <a href="/snowzhao/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-归档">
          <a href="/snowzhao/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-标签">
          <a href="/snowzhao/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br>
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-分类">
          <a href="/snowzhao/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br>
            
            分类
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://vincent_zyt.gitee.io/snowzhao/snowzhao/2019/08/07/studio-快速生成dimens文件/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="snowzhao">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/snowzhao/images/photo.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="snowzhao博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">studio 快速生成dimens文件</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2019-08-07T10:59:13+08:00">
                2019-08-07
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          
            <div class="post-wordcount">
              
                
                <span class="post-meta-item-icon">
                  <i class="fa fa-file-word-o"></i>
                </span>
                
                  <span class="post-meta-item-text">字数统计&#58;</span>
                
                <span title="字数统计">
                  314
                </span>
              

              
                <span class="post-meta-divider">|</span>
              

              
                <span class="post-meta-item-icon">
                  <i class="fa fa-clock-o"></i>
                </span>
                
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                
                <span title="阅读时长">
                  1
                </span>
              
            </div>
          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>创建一个类运行下，快速生成你需要的dimens文件中的数据，解放你每次需要每次添加一个。</p>
<h4 id="第一步：创建一个类"><a href="#第一步：创建一个类" class="headerlink" title="第一步：创建一个类"></a>第一步：创建一个类</h4><p>TestDimenTool(注意文件路径需要写对)，要编写sp、px单位的更改end字符串中的后缀；  </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">public class TestDimenTool &#123;</span><br><span class="line">    public static void main(String[] args) &#123;</span><br><span class="line">        StringBuilder sw400 = new StringBuilder();</span><br><span class="line">        //添加xml开始的标签</span><br><span class="line">        String xmlStart = &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;utf-8\&quot;?&gt;\n&quot; +</span><br><span class="line">                &quot;&lt;resources&gt;\n&quot;;</span><br><span class="line">        sw400.append(xmlStart);</span><br><span class="line">        //添加内容</span><br><span class="line">        for (int i = 0; i &lt; 800; i++) &#123;</span><br><span class="line">//            此处name后的标签名可以自定义&quot;margin_&quot;随意更改</span><br><span class="line">            String start = &quot;&lt;dimen name=\&quot;margin_&quot; + change(i) + &quot;\&quot;&gt;&quot;;</span><br><span class="line">            String end = &quot;dp&lt;/dimen&gt;&quot;;</span><br><span class="line">            sw400.append(start).append(i).append(end).append(&quot;\n&quot;);</span><br><span class="line">        &#125;</span><br><span class="line">        //添加xml的尾标签</span><br><span class="line">        sw400.append(&quot;&lt;/resources&gt;&quot;);</span><br><span class="line">        String sw400file = &quot;./app/src/main/res/values/dimens.xml&quot;;</span><br><span class="line">        writeFile(sw400file, sw400.toString());</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    public static void writeFile(String file, String text) &#123;</span><br><span class="line">        PrintWriter out = null;</span><br><span class="line">        try &#123;</span><br><span class="line">            out = new PrintWriter(new BufferedWriter(new FileWriter(file)));</span><br><span class="line">            out.println(text);</span><br><span class="line">        &#125; catch (IOException e) &#123;</span><br><span class="line">            e.printStackTrace();</span><br><span class="line">        &#125;</span><br><span class="line"> </span><br><span class="line">        out.close();</span><br><span class="line">    &#125;</span><br><span class="line"> </span><br><span class="line">    private static String change(int i) &#123;</span><br><span class="line">        if (i &lt; 100) &#123;</span><br><span class="line">            return &quot;0&quot; + i;</span><br><span class="line">        &#125; else &#123;</span><br><span class="line">            return i + &quot;&quot;;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h4 id="第二步：生成文件"><a href="#第二步：生成文件" class="headerlink" title="第二步：生成文件"></a>第二步：生成文件</h4><p>运行这个类，右击此类==》Run ‘TestDimenTool.main()’   </p>
<p>这样就生成你想要的文件了</p>

      
    </div>
    
    
    

 
<div>
  
    <div>
    
        <div style="text-align:center;color: #666;font-size:16px;">-------------本文结束<i class="fa fa-paw"></i>感谢您的阅读-------------</div>
    
</div>
  
</div>

    

    

    
    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/snowzhao/2019/08/01/readme编写/" rel="next" title="README.md编写教程（基本语法）">
                <i class="fa fa-chevron-left"></i> README.md编写教程（基本语法）
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/snowzhao/2019/08/07/小程序-js中map转数组/" rel="prev" title="小程序 js中map转数组">
                小程序 js中map转数组 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image" src="/snowzhao/images/photo.png" alt="snowzhao">
            
              <p class="site-author-name" itemprop="name">snowzhao</p>
              <p class="site-description motion-element" itemprop="description">给自己每天浇点水,迟早会长成一棵大树</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/snowzhao/archives">
              
                  <span class="site-state-item-count">11</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/snowzhao/categories/index.html">
                  <span class="site-state-item-count">4</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                <a href="/snowzhao/tags/index.html">
                  <span class="site-state-item-count">4</span>
                  <span class="site-state-item-name">标签</span>
                </a>
              </div>
            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/zhaoyingtao" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-github"></i>GitHub</a>
                  </span>
                
                  <span class="links-of-author-item">
                    <a href="https://blog.csdn.net/qq_31796651" target="_blank" title="CSDN">
                      
                        <i class="fa fa-fw fa-stack-overflow"></i>CSDN</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-4"><a class="nav-link" href="#第一步：创建一个类"><span class="nav-text">第一步：创建一个类</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#第二步：生成文件"><span class="nav-text">第二步：生成文件</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2019</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">snowzhao</span>

<!-- 取消英文统计数字
  
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
    
      <span class="post-meta-item-text">Site words total count&#58;</span>
    
    <span title="Site words total count">7.4k</span>
  
-->
</div>
<!-- 取消默认 由 hexo 强力驱动 | 主题 next。pisces v5.1.4

  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>



-->



<span class="post-meta-divider"> 坚持 </span>

<span class="post-meta-divider"> | </span>

<div class="theme-info">
  <div class="powered-by"></div>
  <span class="post-count">博客全站共 7.4k 字</span>
</div>

        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/snowzhao/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/snowzhao/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/snowzhao/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/snowzhao/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/snowzhao/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/snowzhao/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/snowzhao/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/snowzhao/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/snowzhao/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

<script src="/snowzhao/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/snowzhao/live2dw/assets/assets/z16.model.json"},"display":{"position":"right","width":300,"height":500},"mobile":{"show":false},"log":false});</script></body>
</html>
